<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../js/jquery-1.9.1.js"></script>
	<title>首页</title>
</head>
<body>
<div class="container-fluid">
	<div class="row">
		<div id="login_ajax">
			<div class="col-xs-12">
				<div class="user-picture">
					<a href="javascript:;">
						<img src="">
					</a>
					<p>未登录</p>
				</div>
			</div>
			<div class="col-xs-12">
				<div class="login-box">
					<div class="col-xs-3">
						用户状态
					</div>
					<div class="col-xs-9">

					</div>
				</div>
			</div>
		</div>
		<div class="col-xs-12">
			<div class="login-box">
				<div class="col-xs-3">
					到期时间
				</div>
				<div class="col-xs-9">
					2012-10-24
				</div>
			</div>
		</div>
		<div class="col-xs-12 login-class">
			<div class="col-xs-3"><a href="" class="active">登陆</a></div>
			<div class="col-xs-3"><a href="recharge.html">充值</a></div>
			<div class="col-xs-3"><a href="query.html">查询</a></div>
			<div class="col-xs-3"><a href="register.html">注册</a></div>
		</div>
		<div class="col-xs-12" id="loginFrom">
			<diva class="login-main">
				<div class="col-xs-2">
					账号
				</div>
				<div class="col-xs-10">
					<input type="text"/>
				</div>
				<div class="col-xs-2">
					密码
				</div>
				<div class="col-xs-10">
					<input type="text"/>
				</div>
				<div class="col-xs-4 col-xs-offset-8">
					<input type="submit" class="submit" onclick="logindo()" value="登陆"/>
				</div>
			</div>
		</div>
	</div>
	<footer>
		<div class="col-xs-3 col-xs-offset-2">
			<a href="index.html" class="btn_1_yes"></a>
		</div>
		<div class="col-xs-3">
			<a href="../game/index.html" class="btn_2"></a>
		</div>
		<div class="col-xs-3">
			<a href="../set/index.html" class="btn_3"></a>
		</div>
	</footer>
</div>
</body>
</html>
<script src="../../js/jquery.jsonp.js"></script>
<script type="text/javascript" src="../../js/startmove.js"></script>
<script src="../../js/dataRequest.js" type="text/javascript">
</script>
<script>
	 loginState();
	 // s判断登录状态
	 function loginState(){
		   var indexUrl = "http://aaa.57810.mom/index.php/Index/index";
		   $.ajax({
				 type : "get",
				 url : indexUrl,
				 dataType : "jsonp",
			     data:"{}",
				 jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
				 jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
				 success : function(json){
					   if(json['isLogin']!=false){
						    // 变更dom
						    var login = document.getElementById('login_ajax');
						    var loginForm = document.getElementById("loginFrom");
                            html = '<div class="col-xs-12"><div class="user-picture"><a href="javascript:;"><img src=""></a><p>'+json['nickname']+'</p></div></div><div class="col-xs-12"><div class="login-box"><div class="col-xs-3">用户状态</div>' ;
						    if(json['userType']=="USER_TYPE_NORMAL") {
								html += '<div class="col-xs-9">普通</div></div></div>';
							}
						   if(json['userType']=="USER_TYPE_vip") {
							   html += '<div class="col-xs-9">vip</div></div></div>';
						   }
                           login.innerHTML = html;
						   loginForm.innerHTML = '<a href="javascript:loginOut()" class="loginOut">退出登录</a>';
					   }
				 },
				 error:function(XMLHttpRequest, textStatus, errorThrown){

					 alert(XMLHttpRequest.status);
					 alert(XMLHttpRequest.readyState);
					 alert(textStatus);
					 alert(errorThrown);
				 },
			 });
		  }
	 //创建提示框
	 function creatLayout(Html){
		 var Layout = document.createElement('div');
		 Layout.className = 'code_tips';
		 Layout.innerHTML = Html;
		 document.body.appendChild(Layout);
		 Move(Layout,'opacity',100);
		 setTimeout(function(){
			 Move(Layout,'opacity',0);
			 setTimeout(function(){
				 document.body.removeChild(Layout);
			 },500)
		 },1000)
	 }
	 // 登陆
	 function logindo() {
		 var url = "http://aaa.57810.mom/index.php/Index/login_do";
		 var login_main = document.getElementsByClassName("login-main")[0].getElementsByTagName('input');
		 if(login_main[0].value==''||login_main[1].vlaue==''){
			    creatLayout("登陆信息不能为空");
			    return;
		 }
		 var data = {account:login_main[0].value,password:login_main[1].value};
		 $.ajax({
			 type : "get",
			 async : false,  //同步请求
			 url : url,
			 dataType : "jsonp",
			 data:data,
			 jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
			 jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
			 contentType: "application/x-www-form-urlencoded; charset=utf-8",
			 success : function(json){
				 if(json['code']==200){
					    window.location.reload();
				 }else{
					   creatLayout("用户名或密码错误");
				 }
			 },
			 error:function(XMLHttpRequest, textStatus, errorThrown){
				 alert(XMLHttpRequest.status);
				 alert(XMLHttpRequest.readyState);
				 alert(textStatus);
				 alert(errorThrown);
			 },
		 });

	 }

	 function dump_obj(myObject) {
		 var s = "";
		 for (var property in myObject) {
			 s = s + "\n "+property +": " + myObject[property] ;
		 }
		 alert(s);
	 }

	 //退出登陆
		  function loginOut(){
			  var url = "http://aaa.57810.mom/index.php/Index/loginOut";
			  $.ajax({
				  type : "get",
				  url : url,
				  dataType : "jsonp",
				  jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
				  jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
				  success : function(json){
					   if(json['code']==1){
						   window.location.reload();
					   }
				  },
				  error:function(XMLHttpRequest, textStatus, errorThrown){
					  alert(XMLHttpRequest.status);
					  alert(XMLHttpRequest.readyState);
					  alert(textStatus);
					  alert(errorThrown);
				  },
			  });
		  }
</script>
